/*
package com.powernode.teatraceability.service.contract.impl;


import com.powernode.teatraceability.constant.CustomerConstant;
import com.powernode.teatraceability.dao.depositevidence.EntCerInfoMapper;
import com.powernode.teatraceability.service.contract.CertificatesService;
import com.powernode.teatraceability.vo.EnterpriseCertificateVo;
import com.powernode.teatraceability.vo.ProductCertificateVo;
import lombok.extern.slf4j.Slf4j;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple6;
import org.fisco.bcos.sdk.abi.datatypes.generated.tuples.generated.Tuple7;
import org.fisco.bcos.sdk.client.Client;
import org.fisco.bcos.sdk.model.TransactionReceipt;
import org.fisco.bcos.sdk.transaction.model.exception.ContractException;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.math.BigInteger;

*/
/**
 * ClassName: CertificatesServiceImpl
 * Description:
 *
 * @Author: jdz
 * @Create: 2023/4/27 - 11:05
 *//*

@Service
@Slf4j
public class CertificatesServiceImpl implements CertificatesService {
    @Value("${system.contract.certificatesAddress}")
    private String contractAddress;
    @Value("${fisco.bcos.account.address}")
    private String accountAddress;
    @Resource
    private Client client;
    @Resource
    EntCerInfoMapper entCerInfoMapper;

    @Override
    public boolean applyEnterpriseCertificate(String _enterpriseName, String _enterpriseFzr, String _certificateStandard, String _certificateMaterial) {
        final Certificates cer = Certificates.load(contractAddress, client, client.getCryptoSuite().getCryptoKeyPair());
        final TransactionReceipt transactionReceipt = cer.applyEnterpriseCertificate(accountAddress, _enterpriseName, _enterpriseFzr, _certificateStandard, _certificateMaterial);
        log.info("applyEnterpriseCertificate traction receipt {}", transactionReceipt.toString());
        final String status = transactionReceipt.getStatus();
        return CustomerConstant.SUCCESS_STATUS.equals(status);
    }

    @Override
    public boolean applyProductCertificate(String _productName, String _enterpriseName, String _certificateType, String _certificateMaterial) {
        final Certificates cer = Certificates.load(contractAddress, client, client.getCryptoSuite().getCryptoKeyPair());
        final TransactionReceipt transactionReceipt = cer.applyProductCertificate(_productName, _enterpriseName, _certificateType, _certificateMaterial);
        log.info("applyProductCertificate traction receipt {}", transactionReceipt.toString());
        final String status = transactionReceipt.getStatus();
        return CustomerConstant.SUCCESS_STATUS.equals(status);
    }

    @Override
    public boolean modifyEnterpriseCertificate(String _enterpriseName, String _enterpriseFzr, String _certificateStandard, String _certificateMaterial) {
        final Certificates cer = Certificates.load(contractAddress, client, client.getCryptoSuite().getCryptoKeyPair());
        final TransactionReceipt transactionReceipt = cer.modifyEnterpriseCertificate(accountAddress, _enterpriseName, _enterpriseFzr, _certificateStandard, _certificateMaterial);
        log.info("modifyEnterpriseCertificate traction receipt {}", transactionReceipt.toString());
        final String status = transactionReceipt.getStatus();
        return CustomerConstant.SUCCESS_STATUS.equals(status);
    }

    @Override
    public boolean modifyProductCertificate(BigInteger _index, String _productName, String _certificateType, String _certificateMaterial) {
        final Certificates cer = Certificates.load(contractAddress, client, client.getCryptoSuite().getCryptoKeyPair());
        final TransactionReceipt transactionReceipt = cer.modifyProductCertificate(_index, _productName, _certificateType, _certificateMaterial);
        log.info("modifyProductCertificate traction receipt {}", transactionReceipt.toString());
        final String status = transactionReceipt.getStatus();
        return CustomerConstant.SUCCESS_STATUS.equals(status);
    }

    @Override
    public String confirmEnterpriseCertificate() {
        final Certificates cer = Certificates.load(contractAddress, client, client.getCryptoSuite().getCryptoKeyPair());
        final TransactionReceipt transactionReceipt = cer.confirmEnterpriseCertificate(accountAddress);
        log.info("confirmEnterpriseCertificate traction receipt {}", transactionReceipt.toString());
        final String status = transactionReceipt.getStatus();
        final String transactionHash = transactionReceipt.getTransactionHash();
        if (CustomerConstant.SUCCESS_STATUS.equals(status)) {
            entCerInfoMapper.selectByQymc()
            return transactionHash;
        } else {
            return null;
        }
    }

    @Override
    public String confirmProductCertificate(BigInteger _index) {
        final Certificates cer = Certificates.load(contractAddress, client, client.getCryptoSuite().getCryptoKeyPair());
        final TransactionReceipt transactionReceipt = cer.confirmProductCertificate(_index);
        log.info("confirmProductCertificate traction receipt {}", transactionReceipt.toString());
        final String status = transactionReceipt.getStatus();
        final String transactionHash = transactionReceipt.getTransactionHash();
        if (CustomerConstant.SUCCESS_STATUS.equals(status)) {
            // 存凭据
            return transactionHash;
        } else {
            return null;
        }
    }

    @Override
    public EnterpriseCertificateVo enterpriseCertificates() {
        final Certificates cer = Certificates.load(contractAddress, client, client.getCryptoSuite().getCryptoKeyPair());
        try {
            final Tuple7<String, String, String, String, String, BigInteger, Boolean> enterpriseInfo = cer.enterpriseCertificates(accountAddress);
            if (enterpriseInfo.getValue1().startsWith("0x00000000000000")) {
                return null;
            } else {
                return new EnterpriseCertificateVo(enterpriseInfo.getValue1(),
                                                                        enterpriseInfo.getValue2(),
                                                                        enterpriseInfo.getValue3(),
                                                                        enterpriseInfo.getValue4(),
                                                                        enterpriseInfo.getValue5(),
                                                                        enterpriseInfo.getValue6(),
                                                                        enterpriseInfo.getValue7());
            }
        } catch (ContractException e) {
            return null;
        }
    }

    @Override
    public ProductCertificateVo productCertificates(BigInteger _index) {
        final Certificates cer = Certificates.load(contractAddress, client, client.getCryptoSuite().getCryptoKeyPair());
        try {
            final Tuple6<String, String, String, String, BigInteger, Boolean> productInfo = cer.productCertificates(accountAddress, _index);
            return new ProductCertificateVo(productInfo.getValue1(),
                                            productInfo.getValue2(),
                                            productInfo.getValue3(),
                                            productInfo.getValue4(),
                                            productInfo.getValue5(),
                                            productInfo.getValue6());
        } catch (ContractException e) {
            System.out.println(e);
            return null;
        }
    }
}
*/
